﻿using MediatR;
using T_settlement.API.Application.Command.settlementCommand;
using T_settlement.Infrastructure.Interfacec;

namespace T_settlement.API.Application.CommandHandlers.settlementCommandHandlers
{
    public class UpdateStateCommandHandlers:IRequestHandler<UpdateStateCommand,int>
    {
        private readonly lsettlementRepository lsettlementRepository;

        public UpdateStateCommandHandlers(lsettlementRepository lsettlementRepository)
        {
            this.lsettlementRepository = lsettlementRepository;
        }

        public async Task<int> Handle(UpdateStateCommand request, CancellationToken cancellationToken)
        {
            var list = await lsettlementRepository.GetModelAsync(request.SettlementId);
            list.CheckState = 1;
            list.UpdateBy = "李四";
            list.UpdateDate = DateTime.Now;
            var res = await lsettlementRepository.UpdateAsync(list);
            return res;
        }
    }
}
